public class Singleton {
    public static void main(String[] args) {
        Singleton s1 = Singleton.getInstance();
        Singleton s2 = Singleton.getInstance();
        System.out.println(s1 == s2);
        System.out.println(s1.hashCode());
        System.out.println(s2.hashCode());
    }

    private Singleton() {
    }

    private static Singleton instance = null;
    private static Object objLock = new Object();
    
    public static Singleton getInstance() {
        if (instance == null) {
            synchronized (objLock) {
                if (instance == null) {
                    instance = new Singleton();
                }
            }
        }
        return instance;
    }
}